<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="IE=edge, chrome=1">
    <title>throttle（节流）</title>
    
    <style>
        #container{
            width: 100%; height: 200px; line-height: 200px; text-align: center; color: #fff; background-color: #444; font-size: 30px;
        }
    </style>
</head>

<body>
    <div id="container"></div>
    <!-- 节流的原理就是：如果你持续触发事件，每隔一段时间，只执行一次事件。 -->
    
    <script type="module">
        import throttle from './js/19_throttle/throttle1.js'
        var count = 1;
        var container = document.getElementById('container');

        function getUserAction(e) {
            container.innerHTML = count++;
            console.log(e)
        };
        // container.onmousemove = getUserAction;
        container.onmousemove = throttle(getUserAction, 1000);
    </script>
</body>

</html>